<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>信任凭据</title>
    <link rel="stylesheet" href="../assets/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../css/font/iconfont.css" media="all">
</head>
<body>
<div class="layui-form-item">
    <table class="layui-table">
        <thead>
        <tr><th>文件名</th>
            <th>操作</th>
        </tr></thead>
        <tbody id="uploadList"></tbody>
    </table>
</div>
</body>
<script src="../assets/layui/layui.js"></script>
<script src="../js/common.js"></script>
<script>
    layui.config({
        base: '../js/'
    });
    var $;
    layui.use(['jquery','common','upload'], function () {
        var upload = layui.upload,
            common = layui.common;
        $ = layui.jquery;

        var fileNames=common.getUrlDecodeParam("fileNames").split(",");
        var filePt =common.getUrlParam("filePt");
        uploadView();
        function uploadView() {
            $.each(fileNames, function (index, t) {
                var tr = $(['<tr id="upload-' + index + '">'
                    , '<td>' + t + '</td>'
                    , '<td>'
                    , '<button class="layui-btn layui-btn-xs layui-btn-danger upload-download">下载</button>'
                    , '</td>'
                    , '</tr>'].join(''));
                //下载
                tr.find('.upload-download').on('click', function () {
                    var form = $("<form>");   //定义一个form表单
                    form.attr('style', 'display:none');   //在form表单中添加查询参数
                    form.attr('target', '_break');
                    form.attr('method', 'post');
                    form.attr('action', "../person/download");
                    var input1 = $('<input>');
                    input1.attr('type', 'hidden');
                    input1.attr('name', 'fileName');
                    input1.attr('value', t );
                    var input2 = $('<input>');
                    input2.attr('type', 'hidden');
                    input2.attr('name', 'filePt');
                    input2.attr('value', filePt );
                    $('body').append(form);  //将表单放置在web中
                    form.append(input1);   //将查询参数控件提交到表单上
                    form.append(input2);
                    form.submit();   //表单提交
                    return false;
                });
                $('#uploadList').append(tr);
            })
        }
    })


</script>
</html>